package com.example.designmodel;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View;

public class FacadeActivity extends AppCompatActivity {

    public static void launch(Context context) {
        Intent intent = new Intent(context, FacadeActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_faced);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

       FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        faceade();
    }

    private void faceade(){
        Facade facade = new Facade();
        facade.doSomethingA();
        facade.doSomethingB();
        facade.doSomethingC();
        facade.doSomethingAB();
        Facade2 facade2 = new Facade2();
        facade2.doSomethingB();
    }

    public static class ConcreateA{
        public void concreateA(){
            Log.i("test","ConcreateA");
        }
    }

    public static class ConcreateB{
        public void concreateB(){
            Log.i("test","ConcreateB");
        }
    }

    public static class ConcreateC{
        public void concreateC(){
            Log.i("test","ConcreateC");
        }
    }

    public static class Facade{
        private ConcreateA a = new ConcreateA();
        private ConcreateB b = new ConcreateB();
        private ConcreateC c = new ConcreateC();
        private ComplexAB ab = new ComplexAB();

        private void doSomethingA(){
            a.concreateA();
        }

        private void doSomethingB(){
            b.concreateB();
        }

        private void doSomethingC(){
            c.concreateC();
        }

        private void doSomethingAB(){
            ab.complexAB();
        }
    }

    public static class ComplexAB{
        private ConcreateA a = new ConcreateA();
        private ConcreateB b = new ConcreateB();
        public void complexAB(){
            a.concreateA();
            b.concreateB();
        }
    }

    public static class Facade2{
        private Facade facade = new Facade();
        public void doSomethingB(){
            facade.doSomethingB();
        }

    }




}
